package com.company.control;

import com.company.bean.GoodssalesBean;
import com.company.model.GoodModel;
import com.company.util.MyUtils;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "JumpServlet", value = "/JumpServlet")
public class JumpServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String strid = request.getParameter("id");
        request.getSession().setAttribute("id",strid);

        //根据id值查询商品的信息
        GoodssalesBean goodssalesBean = MyUtils.getNewInstance(GoodModel.class)
                .selectGoodByid(strid);

        //将查询到的结果集成到session中-缓存数据
        request.getSession().setAttribute("goodssalesBean",goodssalesBean);
        //跳转到修改页面
        request.getRequestDispatcher("/WEB-INF/UpdateGoods.jsp")
                .forward(request,response);
    }

}
